package com.xqb.modules.domain.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

/**
 * 用户领取优惠券的记录，是真正使用的优惠券信息
 *
 * @author 2092466583
 * @TableName mkt_user_coupon
 */
@TableName(value = "mkt_user_coupon")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MktUserCoupon implements Serializable {
    @TableField(exist = false)
    private static final long serialVersionUID = 1L;
    /**
     * 用户券id
     */
    @TableId(type = IdType.AUTO)
    private Long id;
    /**
     * 优惠券的拥有者
     */
    private Long userId;
    /**
     * 优惠券模板id
     */
    private Long couponId;
    /**
     * 优惠券有效期开始时间
     */
    private Date termBeginTime;
    /**
     * 优惠券有效期结束时间
     */
    private Date termEndTime;
    /**
     * 优惠券使用时间（核销时间）
     */
    private Date usedTime;
    /**
     * 优惠券状态，1：未使用，2：已使用，3：已失效
     */
    private Integer status;
    /**
     * 创建时间
     */
    private Date createTime;
    /**
     * 更新时间
     */
    private Date updateTime;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        MktUserCoupon other = (MktUserCoupon) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
                && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
                && (this.getCouponId() == null ? other.getCouponId() == null : this.getCouponId().equals(other.getCouponId()))
                && (this.getTermBeginTime() == null ? other.getTermBeginTime() == null : this.getTermBeginTime().equals(other.getTermBeginTime()))
                && (this.getTermEndTime() == null ? other.getTermEndTime() == null : this.getTermEndTime().equals(other.getTermEndTime()))
                && (this.getUsedTime() == null ? other.getUsedTime() == null : this.getUsedTime().equals(other.getUsedTime()))
                && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
                && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
                && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
        result = prime * result + ((getCouponId() == null) ? 0 : getCouponId().hashCode());
        result = prime * result + ((getTermBeginTime() == null) ? 0 : getTermBeginTime().hashCode());
        result = prime * result + ((getTermEndTime() == null) ? 0 : getTermEndTime().hashCode());
        result = prime * result + ((getUsedTime() == null) ? 0 : getUsedTime().hashCode());
        result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", userId=").append(userId);
        sb.append(", couponId=").append(couponId);
        sb.append(", termBeginTime=").append(termBeginTime);
        sb.append(", termEndTime=").append(termEndTime);
        sb.append(", usedTime=").append(usedTime);
        sb.append(", status=").append(status);
        sb.append(", createTime=").append(createTime);
        sb.append(", updateTime=").append(updateTime);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}